<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('查看订单')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-order-edit" >
            <input name="id" th:field="${order.id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">创建时间：</label>
                <div class="col-sm-8 control-label">
                    <input name="info" th:field="${order.createDate}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">订单编号：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="${order.orderNum}" class="form-control" type="text" >
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">用户信息：</label>

                <div class="col-sm-8 form-group">
                    <div class="row">
                        <label class="col-sm-3 control-label is-required">用户名：</label>
                        <div class="col-sm-8">
                            <input name="name" th:field="${order.user.username}" class="form-control" type="text" required>
                        </div>
                    </div>
                    <div class="row">
                        <label class="col-sm-3 control-label is-required">联系电话：</label>
                        <div class="col-sm-8">
                            <input name="name" th:field="${order.user.phone}" class="form-control" type="text" required>
                        </div>
                    </div>
                    <div class="row">
                        <label class="col-sm-3 control-label is-required">联系电话：</label>
                        <div class="col-sm-8">
                            <input name="name" th:field="${order.user.phone}" class="form-control" type="text" required>
                        </div>
                    </div>

                    <div class="row">
                        <label class="col-sm-3 control-label is-required">收货地址：</label>
                        <div class="col-sm-8">
                            <input name="name" th:field="${order.address.province}" class="form-control" type="text" required>
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">订单信息：</label>

                <div class="col-sm-8 form-group">

                    <div class="row" th:each="items,itemStat:${order.orderItems}">
                        <hr>
                        <label class="col-sm-3 control-label ">序号：</label>
                        <label class="col-sm-8 control-label" style="text-align: left" th:text="${itemStat.count}"></label>

                        <label class="col-sm-3 control-label ">书名：</label>
                        <label class="col-sm-8 control-label" style="text-align: left" th:text="${items.book.name}"></label>
<!--                        <input name="name" th:field="${items.book.name}" class="form-control" type="text" required>-->

                        <label class="col-sm-3 control-label ">单价：</label>
                        <label class="col-sm-8 control-label" style="text-align: left" th:text="${items.book.newPrice}"></label>

                        <label class="col-sm-3 control-label ">数量：</label>
                        <label class="col-sm-8 control-label" style="text-align: left" th:text="${items.count}"></label>

                        <label class="col-sm-3 control-label ">实付款（元）：</label>
                        <label class="col-sm-8 control-label" style="text-align: left" th:text="${items.count * items.book.newPrice}"></label>

                        <label class="col-sm-3 control-label ">交易状态：</label>

                            <label class="col-sm-8 control-label" style="text-align: left;color: black;background-color: red" th:if="${order.orderStatus == '1'}" >已付款，待发货</label>


                            <label class="col-sm-8 control-label" style="text-align: left;color: black;background-color: #00a65a" th:if="${order.orderStatus == '2'}" >已发货，订单完成</label>



                        <hr>
                    </div>

<!--                    <thead>-->
<!--                        <tr class="active">-->
<!--                            <th>序号</th>-->
<!--                            <th>图片</th>-->
<!--                            <th>图片名称</th>-->
<!--                            <th>单价(元)</th>-->
<!--                            <th>数量</th>-->
<!--                            <th>实付款(元)</th>-->
<!--                            <th>付款日期</th>-->
<!--                            <th>交易状态</th>-->
<!--                        </tr>-->
<!--                    </thead>-->
<!--                    <tbody>-->
<!--                    <tr class="warning" th:each="items,itemStat:${order.orderItems}" >-->
<!--                        <td th:text="${items.book.id}">1001</td>-->
<!--                        					自增序号-->
<!--                        <td th:text="${itemStat.count}">1001</td>-->
<!--                        <td><img th:src="${items.book.imgUrl}" src="images/yuannideqingchunbufumengxiang.jpg"></td>-->
<!--                        <td th:text="${items.book.name}">愿你的青春不负梦想</td>-->
<!--                        <td th:text="${items.book.newPrice}">80.0</td>-->
<!--                        <td th:text="${items.count}">2</td>-->
<!--                        <td th:text="${items.count * items.book.newPrice}">160.0</td>-->
<!--                        <td th:text="${#calendars.format(order.createDate,'dd/MM/yyyy')}">01/08/2017</td>-->
<!--                        <td th:text="${order.orderStatus == '1' ? '已付款':'订单完成'}">未付款1</td>-->

<!--                    </tr>-->
<!--                    </tbody>-->


                </div>
            </div>

            <div style="text-align: center" >
                <button th:if="${order.orderStatus == '1'}" class="btn-warning" style="margin: 0 auto;font-size: 17px;" onclick="sub()">确认发货</button>
                <button th:if="${order.orderStatus == '2'}" class="btn-primary" style="margin: 0 auto;font-size: 17px;" >已发货</button>
            </div>

        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">

        var prefix = ctx + "business/order";
        $("#form-order-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-order-edit').serialize());
            }
        }

        function sub(){
            let id = "[[${order.id}]]";
            var url = prefix+"/submit?id="+id;

            $.ajax({
                url:url,
                method:"get",
                success:function (result) {
                    // alert(result)

                }
            })
            alert("发货成功")
            $.modal.closeAll();//关闭
            location.href=prefix//访问当前页面

            // location.reload()
            // window.location.href;
            // location.reload([bForceGet])   //重新加载当前文档
            // location=location

        }
    </script>
</body>
</html>